$(function(){
	data(getUrl('syUser', 'Get_IsLogin'), '', 'json', islogin);
});

function loginFun() {
	data_ = {
		userid: $('#username').val(),
		password: $('#password').val()
	};
	data(getUrl('syUser', 'Login'), data_, 'json', islogin);
}

function islogin(d) {
	if (d.islogin==0) {
		data(getUrl('syParameter', 'Get_LoginWebInfo'), '', 'json', loginweb);
	} else {
		data(getUrl('syParameter', 'Get_MainWebInfo'), '', 'json', web);
	}
}

function web(d) {
	$.each(d,
	function(k, v) {
		set(k, v);
	});
	goMain();
}

function loginweb(d) {
	$.each(d,function(k, v) {set(k, v);});
}

function loginFun() {
	data_ = {
		userid: $('#username').val(),
		password: $('#password').val()
	};
	data(getUrl('syUser', 'Login'), data_, 'json', islogin);
}

function roleHtml(v) {
	var html = '';
	var vs = v.split(',');
	for (var i = 0; i < vs.length; i++) {
		html += '<a style="font-weight:bold;color:#666666;text-decoration: underline;margin:0px;padding:0px;" href="javascript:void(0)" onclick="cRole(this)" >' + vs[i] + '</a>,';
	}
	return html;
}

function menu(v){
var obj=$('#'+v.pid);
	$.each(v.menus,
			function(i, n) {
				var menulist = '';
				menulist += '<li id="' + n.menuid + '" ref="' + n.menuid + '"   href="javascript:void(0);" data-role="list-divider" >' + n.menuname + '</li>';
				$.each(n.menus,
				function(j, o) {
					menulist += '<li onclick="menuclick(this)" name="' + o.menuname + '" ref="' + o.menuid + '"  cmshref="' + o.url + '" href="javascript:void(0);" >' + o.menuname + '</li>';
				});
				obj.append(menulist);
			});
}

function menuclick(obj){
	var url=$(obj).attr('cmshref');
	$.mobile.changePage(url+'_m', {transition:g_transition,changeHash: false}); 
	g_module=url.replaceAll(g_url,'');
}